package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.RoomPersonalInfo;
import com.eling.elcms.travel.service.IRoomPersonalInfoManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Controller
public class RoomPersonalInfoController extends BaseFormController{

	@Autowired
	private IRoomPersonalInfoManager roomPersonM;
	
	@RequestMapping("/api/roompersonalInfo/save")
    @ResponseBody
	public RoomPersonalInfo save(@ModelAttribute@ModelFilling RoomPersonalInfo roomPerson){
		return roomPersonM.save(roomPerson);
	}
	
	@RequestMapping("/api/roompersonalInfo/saveappointment")
	@ResponseBody
	public RoomPersonalInfo saveAppointment(@ModelAttribute@ModelFilling RoomPersonalInfo cond,
			@RequestParam(value = "waterElectric") Boolean waterElectric,
			@RequestParam(value = "breakfast") Boolean breakfast,
			@RequestParam(value = "checkInPrice")Double checkInPrice){
		return roomPersonM.saveAppointment(cond,waterElectric,breakfast,checkInPrice);
	}
	
	@RequestMapping("/api/roompersonalInfo/savecancel")
	@ResponseBody
	public RoomPersonalInfo saveCancel(@ModelAttribute@ModelFilling RoomPersonalInfo cond,
			@RequestParam(value = "waterElectric") Boolean waterElectric,@RequestParam(value = "breakfast") Boolean breakfast){
		return roomPersonM.saveCancel(cond,waterElectric,breakfast);
	}
	
	@RequestMapping("/api/roompersonalInfo/{pkRoomPersonalInfo}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkRoomPersonalInfo){
		roomPersonM.remove(pkRoomPersonalInfo);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/roompersonalInfo/query")
    @ResponseBody
	public List<RoomPersonalInfo> query(@ModelAttribute RoomPersonalInfo roomPerson){
		return roomPersonM.query(roomPerson);
	}
	
	@RequestMapping("/api/roompersonalInfo/search*")
	@ResponseBody
	public List<RoomPersonalInfo> search(@ModelAttribute SearchCondition sc,@ModelAttribute RoomPersonalInfo roomPerson){
		sc.setQueryCondition(roomPerson);
		return roomPersonM.search(sc);
	}
}

